<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// 图书管理

// 图书列表
Route::get("/book/list","home\BookController@list");
Route::post("/book/add","home\BookController@add");
Route::post("/book/create","home\BookController@create");
Route::post("/book/update","home\BookController@update");
Route::post("/book/del","home\BookController@del");
Route::post("/book/is_exist","home\BookController@is_exist");

Route::get("/house/list","home\HouseController@list");
//Route::get("/house/detail","home\HouseController@detail");
//Route::get("/house/detail/{id}","home\HouseController@detail");
Route::post("/house/detail","home\HouseController@detail");
Route::post("/house/search","home\HouseController@search"); // 搜索
Route::post("/house/save","home\HouseController@save"); // vue
Route::post("/house/store","home\HouseController@store");//wechart
Route::post("/house/update","home\HouseController@update"); // 上传图片
Route::post("/house/upload","home\HouseController@upload");
Route::get("/house/my_house","home\HouseController@my_house");
Route::post("/house/del","home\HouseController@del");
Route::get("/house/sale","home\HouseController@sale");
Route::post("/house/delimg","home\HouseController@delimg");
Route::post("/house/state","home\HouseController@state");  // 房源上架 | 下架
Route::get("/house/restore","home\HouseController@restore");

// 小程序专用api接口

// 用户登录
Route::post("/user/token","home\UserController@token");
Route::post("/admin/adduser","admin\UserController@adduser");

// 创建管理员用户
Route::post("/admin/login","admin\UserController@login");
// 管理员用户列表
Route::get("/admin/users","admin\UserController@users");
// 获取单个管理员
Route::get("/admin/user/{id}","admin\UserController@user");
// 更新用户信息
Route::post("/admin/edit","admin\UserController@edit");
// 更新用户状态
Route::post("/admin/update","admin\UserController@update");
// 删除用户
Route::post("/admin/del/{id}","admin\UserController@del");
// 获取菜单
Route::get("/menus","admin\MenuController@menus");

Route::get("/house/like","home\HouseController@like");       //关注
Route::get("/house/unlike","home\HouseController@unlike");   //取消关注

Route::get("/msgs","home\MsgController@msgs");      // 用户获取自己发布的消息
Route::post("/msg/save","home\MsgController@save"); // 小程序用户发布问题

Route::get("/user","home\UserController@user");                // 获取用户
Route::get("/user/my_likes","home\UserController@my_likes");   // 我的关注
Route::get("/user/my_houses","home\UserController@my_houses"); // 我的发布

require_once('vue_api.php');

// 认证路由;
//Route::group(["middleware"=>"token"],function(){
    
    // 登陆用户才能访问后台首页
    // Route::get("/v1/house/my_house","home\HouseController@my_house");
    // Route::get("/v1/house/like/{id}","home\HouseController@like");
    // Route::get("/v1/house/liked/{id}","home\HouseController@liked");

//});


// Route::middleware('auth:api')->get('/user', function (Request $request) {
//     return $request->user();
// });

// Route::middleware('auth:wechat')->get('/user', function (Request $request) {
//     return $request->user();
// });

/*
Route::prefix('v1')->middleware('auth:wechat')->group(function() {
    Route::get("/house/my_house","home\HouseController@my_house");
});
*/

